﻿using UnityEngine;
using System.Collections;

namespace AutoRoot
{
   public class PutOnUpperCenter : MonoBehaviour
   {
      // Use this for initialization
      void Start()
      {
         //Put it on the upper center of screen
         Vector3 bottomLeft = Camera.main.WorldToScreenPoint(new Vector3(renderer.bounds.min.x, renderer.bounds.min.y, 0));
         Vector3 upperRight = Camera.main.WorldToScreenPoint(new Vector3(renderer.bounds.max.x, renderer.bounds.max.y, 0));
         Vector3 upperCenter = new Vector3((float)Screen.width / 2, (float)Screen.height - ((upperRight.y - bottomLeft.y) / 2), 1);
         transform.position = Camera.main.ScreenToWorldPoint(upperCenter);

      }
   }
}
